<template>
  <div class="container">
    <div class="demo">
      <wxc-minibar :title="title"
                  background-color="#009ff0"
                  text-color="#FFFFFF">
        <image v-if="!isFirstPage" :src="'back.png' | getUrl" slot="left" class="back" @click="back"/>
        <image v-if="isFirstPage" :src="'close.png' | getUrl" slot="left" class="back" @click="back"/>
      </wxc-minibar>
    </div>
  </div>
</template>

<script>
import { WxcMinibar } from 'weex-ui'
export default {
  props: {
    title: String
  },
  data () {
    return {
      isFirstPage: false
    }
  },
  components: { WxcMinibar },
  methods: {
    back () {
      this.$router.go(-1)
    }
  },
  created () {
    if (this.title === '首页') {
      this.isFirstPage = true
    }
  },
  filters: {
    getUrl (str) {
      if (weex.config.env.platform === 'Web') {
        return './web/assets/' + str
      } else {
        return 'local:///' + str.split('.')[0]
      }
    }
  }
}
</script>

<style scoped>
.container {
  height: 90px;
}
.back {
  width: 40px;
  height: 40px;
}
</style>
